﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Basic;
using Interface;

namespace Client
{
    public partial class UIManager
    {
        #region global shield
        /// <summary>
        /// Shiled界面显示的原因
        /// </summary>
        private int[] m_GlobalShiledReasonCount;

        private void InitGlobalShield()
        {
            m_GlobalShiledReasonCount = new int[(int)EUIGlobalShieldReason.Count];
            for (int i = 0; i < m_GlobalShiledReasonCount.Length; ++i)
            {
                m_GlobalShiledReasonCount[i] = 0;
            }
        }

        /// <summary>
        /// 增加全局屏蔽计数
        /// </summary>
        /// <param name="reason"></param>
        public void AddGlobalShieldReason(EUIGlobalShieldReason reason)
        {
            m_GlobalShiledReasonCount[(int)reason]++;
            UpdateGlobalShield(true);
        }
        /// <summary>
        /// 降低全局屏蔽计数
        /// </summary>
        /// <param name="reason"></param>
        public void SubGlobalShieldReason(EUIGlobalShieldReason reason)
        {
            if (m_GlobalShiledReasonCount[(int)reason] > 0)
            {
                m_GlobalShiledReasonCount[(int)reason]--;
                UpdateGlobalShield(false);
            }
        }
        private void UpdateGlobalShield(bool add)
        {
            int count = 0;
            for (int i = 0; i < m_GlobalShiledReasonCount.Length; ++i)
            {
                count += m_GlobalShiledReasonCount[i];
            }

            Log.Debug("UIManager.UpdateGlobalShield {0} {1}", add, count);

            if (add)
            {
                if (count == 1)
                {
                }
            }
            else
            {
                if (count == 0)
                {

                }
            }
        }
        #endregion
    }
}
